<script setup>
//导入响应式函数
import {ref} from 'vue'

const style = ref('style1')
//定义匿名函数
const changeColor = ()=>{ //箭头函数
  //===:恒等 value：析构，解包
    if (style.value === 'style1'){
      style.value = 'style2'
    }else{
      style.value = 'style1'
    }
}
</script>

<template>
    <div :class="style" @click="changeColor"></div>
</template>

<style scoped>
  .style1{
    width: 120px;
    height: 120px;
    background-color: red;
  }
  .style2{
    width: 200px;
    height: 200px;
    background-color: blue;
  }
</style>